package Model.Beans.Results;

import java.util.*;
import Model.Beans.*;
import Model.XML.*;

public class ClassRoomList implements XMLRequestInterface {
    
    private ArrayList classrooms;
    private XMLWriter xml;
    
    public ClassRoomList() 
    {
        classrooms = new ArrayList();
        xml = new XMLWriter();
    }    
    
    public void addClass(ClassRoom classroom)
    {
        classrooms.add(classroom);
    }
    
    public ArrayList getClassrooms()
    {
        return classrooms;
    }
    
    public String toXML()
    {
        xml.Push("classroom-list");
        if(classrooms.size() > 0)
        {
            for(int i=0; i<classrooms.size(); i++)
            {
                ClassRoom tmp = (ClassRoom)classrooms.get(i);
                xml.Element("classroom", tmp.toString(), Integer.toString(tmp.getId()));
            }
        }
        else
        {
            xml.Element("classroom", "no-result", "0");
        }
        xml.Pop();
        return xml.GetXML();
    }
}
